﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace syh876.com.Areas.User.Code
{
    public class IdentityHelper
    {
        public static ClientUser ClientUser
        {
            get
            {
                ClientUser ClientUser = null;
                if (HttpContext.Current.Session["CurrentClient"] != null)
                {
                    ClientUser = HttpContext.Current.Session["CurrentClient"] as ClientUser;

                }
                else
                {
                    ClientUser = new ClientUser();

                    ClientUser.LoginResult = false;
                }
                return ClientUser;
            }
            set
            {
                HttpContext.Current.Session["CurrentClient"] = value;
                HttpContext.Current.Session.Timeout = 20160;
            }
        }

        public static bool IsAllow()
        {
            return IdentityHelper.ClientUser.LoginResult;
        }

        public static void LoginOut()
        {
            ClientUser = null;
    
            SYH.Utils.JsHelper.ParentRedirect("/account/logon");
        }
    }
}